<template>
  <el-tree
    :data="userOrgTree"
    @node-click="(data) => $emit('click-node', data)"
    node-key="id"
    :props="{
      label: 'name',
      children: 'children',
    }"
    :default-expanded-keys="department"
  />
</template>

<script>
import { defineComponent } from 'vue'
import useUserOrgTree from '@/hooks/useUserOrgTree'
import Cookies from 'js-cookie'

export default defineComponent({
  emits: {
    'click-node': null,
  },
  props: {},

  setup() {
    const { userOrgTree } = useUserOrgTree()

    return {
      userOrgTree,
      department: Cookies.get('user_unit_id'),
    }
  },
})
</script>

